<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>Worker</title>
    </head>
    <body>
        <h2>Worker Test</h2>
        <div id="output"></div>
        <script type="text/javascript">
            document.addEventListener("DOMContentLoaded", function () {
                console.log("Page Loaded. Sending message");
                console.log("Parent Keys: ", JSON.stringify(Object.keys(this)));

                var work = new Worker("worker.js");
                work.onmessage = (evt) => {
                    console.log("Got message from worker:", evt.data);
                };

                document
                    .getElementById("btn_hello")
                    .addEventListener("click", function() {
                        console.log("Sending Message");
                        work.postMessage({ "msg": "Hey buddy!" });
                    });
            });
        </script>

        <button id="btn_hello">
            Say Hello!
        </button>
    </body>
</html>
